# 处理主角的类。领域、夹击等地图效果
class Game_Player < Game_Character
  # 增加步数
  def increase_steps
    super
    # 不是强制移动路线的场合
    unless @move_route_forcing
      # 增加步数
      $game_party.increase_steps
      # 获取怪物信息
      data = EnemyInfo.getCoordinate
      # 处理领域
      for it in data
        einfo = Game_EnemyInfo.new(it[0])
        # 怪物有领域技能且与玩家曼哈顿距离小于等于1
        if (einfo.eskill == 6) && ((it[1] - $game_player.x).abs + (it[2] - $game_player.y).abs <= 1)
          # 获取伤害
          d = $data_enemies[it[0]].maxsp
          # 绘制角色挨打动画
          a_id = $data_skills[6].animation2_id
          @animation_id = a_id if a_id > 0
          # 计算伤害
          $game_party.actors[0].hp -= [$game_party.actors[0].hp, d].min
          # 死亡判断
          if $game_party.all_dead?
            $game_system.se_play($data_system.actor_collapse_se)
            $game_temp.gameover = true
            return
          end
        end
      end
      # 处理阻击
      for it in data
        einfo = Game_EnemyInfo.new(it[0])
        # 计算相对位置
        dx = it[1] - $game_player.x
        dy = it[2] - $game_player.y
        # 怪物有阻击技能且与玩家曼哈顿距离小于等于1
        if (einfo.eskill == 8) && (dx.abs + dy.abs <= 1)
          # 获取伤害
          d = $data_enemies[it[0]].maxsp
          # 绘制角色挨打动画
          a_id = $data_skills[8].animation2_id
          @animation_id = a_id if a_id > 0
          # 计算伤害
          $game_party.actors[0].hp -= [$game_party.actors[0].hp, d].min
          # 死亡判断
          if $game_party.all_dead?
            $game_system.se_play($data_system.actor_collapse_se)
            $game_temp.gameover = true
            return
          end
          # 移动阻击怪物
          $game_map.events[it[3]].move_left if (dx == -1) && (dy == 0)
          $game_map.events[it[3]].move_right if (dx == 1) && (dy == 0)
          $game_map.events[it[3]].move_up if (dx == 0) && (dy == -1)
          $game_map.events[it[3]].move_down if (dx == 0) && (dy == 1)
        end
      end
      # 处理夹击
      data2 = {}
      for it in data
        einfo = Game_EnemyInfo.new(it[0])
        # 怪物有夹击技能
        if einfo.eskill == 7
          # 计算相对位置
          dx = it[1] - $game_player.x
          dy = it[2] - $game_player.y
          # 如果夹击怪物在玩家的邻接位置则记录
          if dx.abs + dy.abs == 1
            data2[[dx, dy]] = true
          end
        end
      end
      # 处理夹击的两种情况（上下和左右）
      if data2.include?([1, 0]) && data2.include?([-1, 0])
        # 获取伤害
          d = $game_party.actors[0].hp / 2
          # 绘制角色挨打动画
          a_id = $data_skills[7].animation2_id
          @animation_id = a_id if a_id > 0
          # 计算伤害
          $game_party.actors[0].hp -= d
      end
      if data2.include?([0, 1]) && data2.include?([0, -1])
        # 获取伤害
          d = $game_party.actors[0].hp / 2
          # 绘制角色挨打动画
          a_id = $data_skills[7].animation2_id
          @animation_id = a_id if a_id > 0
          # 计算伤害
          $game_party.actors[0].hp -= d
      end
      # 步数是偶数的情况下
      if $game_party.steps % 2 == 0
        # 检查连续伤害
        $game_party.check_map_slip_damage
      end
    end
  end
end
